package design_patterns

//单例模式
import "fmt"

type singleton struct{}

var instance *singleton

func GetInstance() *singleton {
	if instance == nil {
		instance = &singleton{}
		fmt.Println("Creating new instance")
	} else {
		fmt.Println("Using existing instance")
	}
	return instance
}

func (s *singleton) showMessage() {
	fmt.Println("Hello, I am a Singleton.")
}
